#ifndef _AI_SPEECH_RECOGNITION_HEAD_H
#define _AI_SPEECH_RECOGNITION_HEAD_H

#include "snowboy-detect.h"
#include <stdio.h>
#include <iostream>
#include "linux-alsa-sound.h"
#include <thread>
#include "baidu-ai-asr.h"

using namespace std;

class AISpeechRecognition
{
public:
    AISpeechRecognition(const string &audioDevevice = "plughw:1,0");
    bool start(void);
    void stop(void);
    // 开启一个不停录制音频的线程
    void aiAudioThreadRun(void);
    // 识别用户的声音
    void recognitionUserSpeedchData(void);
    void playAckAudio(void);
    // 延时时间
    static void handleTimeOut(int signum);

private:
    static bool wakeState; // 唤醒标志
    bool aiThreadRunFlag;
    string accessToken;
    thread *aiThread; // 录制音频的线程
    string audioDevice;
    snowboy::SnowboyVad *vad;
    snowboy::SnowboyDetect *detector;
    LinuxAlsaSound alsaSound;
    vector<uint8_t> userSpeechData;
    BaiduAiAsr *basr;
};

#endif